<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .active{
        color:red;
    }
  </style>
</head>
<body>
<div id="app">
  <!-- 设置列表第一行默认是红色的，然后点击哪行哪行变成红色-->
  <ul>
    <li v-for="(movie,index) in movies"
        :class="{active : currentIndex===index}"
        @click="liClick(index)">
      {{movie}}</li>
  </ul>
  
  <!--
   <li :class="{active:  currentIndex===0}"  >山河令</li>
   点击触发liClick()方法, active:1==1 即active:true  <li class:active>
   <li :class="{active:  currentIndex===1}" >天官赐福</li>
   <li :class="{active:  currentIndex===2}" >死亡笔记</li>
   <li :class="{active:  currentIndex===3}" >火影忍者</li>
  -->
</div>

<script src="../js/vue.js"></script>
<script>
  const app=new Vue({
    el: '#app',
    data: {
      movies:['山河令','天官赐福','死亡笔记','火影忍者'],
      currentIndex:0   /*这个参数记录当前选中第几个元素*/
    },
    methods:{
      liClick(index){
        this.currentIndex=index;
      }
    }
  })

</script>
</body>
</html>